#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/6/21 0:10
# @Author  : summer
# @Email   : 610658552@qq.com
# @File    : ser_login.py
# @Software: PyCharm
# @Desc    :
from rest_framework import serializers


class LoginSerializer(serializers.Serializer):
    username = serializers.CharField(required=True, max_length=100)
    password = serializers.CharField(required=True, max_length=100, write_only=True)

    def validate(self, data):
        username = data.get('username')
        password = data.get('password')
        if not username or not password:
            raise serializers.ValidationError({'code': 200, 'msg': '用户名和密码不能为空'})
        return data

